<?php

namespace addons\yungift;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Yungift extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        $menu = [
            [
                'name'    => 'yungift',
                'title'   => '礼品兑换',
                'icon'    => 'fa fa-heart',
                'sublist' => [
                    [
                        'name'    => 'yungift/dashboard',
                        'title'   => '数据概览',
                        'icon'    => 'fa fa-dashboard',
                        'weigh'   => 110,
                        'sublist' => [
                            ['name' => 'yungift/dashboard/index', 'title' => '数据概览'],
                        ]
                    ],
                    [
                        'name'    => 'yungift/config',
                        'title'   => '基础设置',
                        'icon'    => 'fa fa-cogs',
                        'weigh'   => 100,
                        'sublist' => [
                            ['name' => 'yungift/config/index', 'title' => '基础设置'],
                        ]
                    ],
                    [
                        'name'    => 'yungift/card',
                        'title'   => '礼卡提货',
                        'icon'    => 'fa fa-archive',
                        'weigh'   => 90,
                        'sublist' => [
                            [
                                'name'    => 'yungift/card/config',
                                'title'   => '入口设置',
                                'icon'    => 'fa fa-shield',
                                'weigh'   => 100,
                                'sublist' => [
                                    ['name' => 'yungift/card/config/index', 'title' => '入口设置'],
                                ]
                            ],
                            [
                                'name'    => 'yungift/card/code',
                                'title'   => '卡密管理',
                                'icon'    => 'fa fa-key',
                                'weigh'  => 90,
                                'sublist' => [
                                    ['name' => 'yungift/card/code/index', 'title' => '查看'],
                                    ['name' => 'yungift/card/code/add', 'title' => '新增'],
                                    ['name' => 'yungift/card/code/edit', 'title' => '编辑'],
                                    ['name' => 'yungift/card/code/del', 'title' => '删除'],
                                    ['name' => 'yungift/card/code/multi', 'title' => '批量更新'],
                                    ['name' => 'yungift/card/code/import', 'title' => '导入'],
                                    ['name' => 'yungift/card/code/export', 'title' => '导出'],
                                    ['name' => 'yungift/card/code/generate', 'title' => '批量生成卡密'],
                                    ['name' => 'yungift/card/code/exportQrcode', 'title' => '下载兑换码'],
                                ]
                            ],
                            [
                                'name'    => 'yungift/card/main',
                                'title'   => '礼卡管理',
                                'icon'    => 'fa fa-vcard',
                                'weigh'   => 80,
                                'sublist' => [
                                    ['name' => 'yungift/card/main/index', 'title' => '查看'],
                                    ['name' => 'yungift/card/main/add', 'title' => '新增'],
                                    ['name' => 'yungift/card/main/edit', 'title' => '编辑'],
                                    ['name' => 'yungift/card/main/del', 'title' => '删除'],
                                    ['name' => 'yungift/card/main/multi', 'title' => '批量更新'],
                                ]
                            ],
                        ]
                    ],
                    [
                        'name'    => 'yungift/fund',
                        'title'   => '礼币兑换',
                        'icon'    => 'fa fa-fire',
                        'weigh'   => 80,
                        'sublist' => [
                            [
                                'name'    => 'yungift/activity',
                                'title'   => '礼品活动',
                                'icon'    => 'fa fa-cubes',
                                'weigh'   => 90,
                                'sublist' => [
                                    ['name' => 'yungift/activity/index', 'title' => '查看'],
                                    ['name' => 'yungift/activity/add', 'title' => '新增'],
                                    ['name' => 'yungift/activity/edit', 'title' => '编辑'],
                                    ['name' => 'yungift/activity/del', 'title' => '删除'],
                                    ['name' => 'yungift/activity/multi', 'title' => '批量更新'],
                                    ['name' => 'yungift/activity/default', 'title' => '默认'],
                                    [
                                        'name'    => 'yungift/fund/user',
                                        'title'   => '礼币账户',
                                        'ismenu'  => 0,
                                        'sublist' => [
                                            ['name' => 'yungift/fund/user/index', 'title' => '查看'],
                                            ['name' => 'yungift/fund/user/del', 'title' => '删除'],
                                            ['name' => 'yungift/fund/user/multi', 'title' => '批量更新'],
                                            ['name' => 'yungift/fund/user/handle', 'title' => '变更账户状态'],
                                            ['name' => 'yungift/fund/user/plus', 'title' => '增加礼币'],
                                            ['name' => 'yungift/fund/user/minus', 'title' => '减少礼币'],
                                            ['name' => 'yungift/fund/user/handleAmount', 'title' => '批量处理礼币'],
                                            [
                                                'name'    => 'yungift/fund/record',
                                                'title'   => '礼币记录',
                                                'ismenu'  => 0,
                                                'sublist' => [
                                                    ['name' => 'yungift/fund/record/index', 'title' => '查看'],
                                                    ['name' => 'yungift/fund/record/del', 'title' => '删除'],
                                                ]
                                            ],
                                        ]
                                    ],
                                ]
                            ],
                            [
                                'name'    => 'yungift/member',
                                'title'   => '成员管理',
                                'icon'    => 'fa fa-user',
                                'weigh'   => 80,
                                'sublist' => [
                                    ['name' => 'yungift/member/index', 'title' => '查看'],
                                    ['name' => 'yungift/member/detail', 'title' => '详情'],
                                    ['name' => 'yungift/member/add', 'title' => '新增'],
                                    ['name' => 'yungift/member/edit', 'title' => '编辑'],
                                    ['name' => 'yungift/member/del', 'title' => '删除'],
                                    ['name' => 'yungift/member/multi', 'title' => '批量更新'],
                                    ['name' => 'yungift/member/import', 'title' => '导入'],
                                    ['name' => 'yungift/member/export', 'title' => '导出'],
                                    ['name' => 'yungift/member/createCode', 'title' => '生成登录码'],
                                    ['name' => 'yungift/member/handleFundUser', 'title' => '操作礼币账户'],
                                ]
                            ],
                            [
                                'name'    => 'yungift/group',
                                'title'   => '分组管理',
                                'icon'    => 'fa fa-group',
                                'weigh'   => 70,
                                'sublist' => [
                                    ['name' => 'yungift/group/index', 'title' => '查看'],
                                    ['name' => 'yungift/group/add', 'title' => '新增'],
                                    ['name' => 'yungift/group/edit', 'title' => '编辑'],
                                    ['name' => 'yungift/group/del', 'title' => '删除'],
                                ]
                            ],
                            [
                                'name'    => 'yungift/member_log',
                                'title'   => '成员日志',
                                'icon'    => 'fa fa-empire',
                                'weigh'   => 60,
                                'sublist' => [
                                    ['name' => 'yungift/member_log/index', 'title' => '查看'],
                                    ['name' => 'yungift/member_log/del', 'title' => '删除'],
                                ]
                            ],
                        ]
                    ],
                    [
                        'name'    => 'yungift/gift/main',
                        'title'   => '礼品管理',
                        'icon'    => 'fa fa-gift',
                        'weigh'   => 70,
                        'sublist' => [
                            ['name' => 'yungift/gift/main/index', 'title' => '查看'],
                            ['name' => 'yungift/gift/main/add', 'title' => '新增'],
                            ['name' => 'yungift/gift/main/edit', 'title' => '编辑'],
                            ['name' => 'yungift/gift/main/del', 'title' => '删除'],
                            ['name' => 'yungift/gift/main/multi', 'title' => '批量更新'],
                            ['name' => 'yungift/gift/main/bind', 'title' => '选择'],
                            [
                                'name'    => 'yungift/gift/code',
                                'title'   => '券码管理',
                                'ismenu'  => 0,
                                'sublist' => [
                                    ['name' => 'yungift/gift/code/index', 'title' => '查看'],
                                    ['name' => 'yungift/gift/code/add', 'title' => '新增'],
                                    ['name' => 'yungift/gift/code/edit', 'title' => '编辑'],
                                    ['name' => 'yungift/gift/code/del', 'title' => '删除'],
                                    ['name' => 'yungift/gift/code/multi', 'title' => '批量更新'],
                                    ['name' => 'yungift/gift/code/import', 'title' => '导入'],
                                ]
                            ],
                        ]
                    ],
                    [
                        'name'    => 'yungift/gift/order',
                        'title'   => '兑换订单',
                        'icon'    => 'fa fa-list',
                        'weigh'   => 60,
                        'sublist' => [
                            ['name' => 'yungift/gift/order/index', 'title' => '查看'],
                            ['name' => 'yungift/gift/order/del', 'title' => '删除'],
                            ['name' => 'yungift/gift/order/export', 'title' => '导出'],
                            ['name' => 'yungift/gift/order/import', 'title' => '导入发货'],
                            ['name' => 'yungift/gift/order/deploy', 'title' => '发货'],
                            ['name' => 'yungift/gift/order/change', 'title' => '修改'],
                            ['name' => 'yungift/gift/order/cancel', 'title' => '取消'],
                            ['name' => 'yungift/gift/order/detail', 'title' => '详情'],
                        ]
                    ],
                    [
                        'name'    => 'yungift/feedback',
                        'title'   => '意见反馈',
                        'icon'    => 'fa fa-list-alt',
                        'weigh'   => 50,
                        'sublist' => [
                            ['name' => 'yungift/feedback/index', 'title' => '查看'],
                            ['name' => 'yungift/feedback/edit', 'title' => '编辑'],
                            ['name' => 'yungift/feedback/del', 'title' => '删除'],
                        ]
                    ],
                    [
                        'name'    => 'yungift/import_log',
                        'title'   => '导入日志',
                        'icon'    => 'fa fa-tint',
                        'weigh'   => 40,
                        'sublist' => [
                            ['name' => 'yungift/import_log/index', 'title' => '查看'],
                            ['name' => 'yungift/import_log/del', 'title' => '删除'],
                        ]
                    ],
                ]
            ]
        ];
        Menu::create($menu);

        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete('yungift');

        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {

        Menu::enable('yungift');

        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {

        Menu::disable('yungift');

        return true;
    }

    /**
     */
    public function appInit()
    {

    }

    /**
     * @param $params
     */
    public function configInit(&$params)
    {

    }
}
